#include"../Client/Rpc_client.hpp"

void Callback(const Json::Value& result)
{
    cout<<"result:"<<result["result"].asInt()<<endl;
}

void test7()
{
    Json::Value params,result;
    params["num1"] = 201;
    params["num2"] = 221;
    zgwrpc::client::RpcClient client(true, "127.0.0.1", 8080);

    cout<<"call Add"<<endl;
    bool ret = client.call("Add", params, result);
    if(ret==false)
    {
        cout<<"call failed"<<endl;
    }
    else 
    {
        cout<<result["result"].asInt()<<endl;
    }

    Json::Value params1;
    params1["num1"] = 999;
    params1["num2"] = 111;
    ret=client.call("Add",params1,Callback);


    std::string str="第五人格";
    Json::Value paramsgame;
    std::future<Json::Value> gameresult;
    paramsgame["game"]=str;
    client.call("Game",paramsgame,gameresult);
    cout<<"result:"<<gameresult.get()<<endl;


    std::this_thread::sleep_for(std::chrono::seconds(2));
}




int main()
{
    test7();
    return 0;
}